import 'package:cat_eye/base/base_refresh_state.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/string_config.dart';
import 'package:cat_eye/root_page/find_page/find_follow_list_widget.dart';
import 'package:cat_eye/util/util.dart';
import 'package:cat_eye/view_model/find_view_model/find_follow_view_model.dart';
import 'package:flutter/material.dart';

/*
* @Package: root_page.find_page
* @ClassName: find_follow_widget
* @Author: szj
* @CreateDate: 8/2/21 10:08 AM
* TODO 发现-关注页面
*/
class FindFollowWidget extends StatefulWidget {
  const FindFollowWidget({Key key}) : super(key: key);

  @override
  _FindFollowWidgetState createState() => _FindFollowWidgetState();
}

class _FindFollowWidgetState
    extends BaseRefreshState<FindFollowWidget, FindFollowViewModel> {
  @override
  FindFollowViewModel get buildViewModel => FindFollowViewModel();

  @override
  Widget buildWidget(BuildContext context, FindFollowViewModel model) {
    return ListView.separated(
      itemBuilder: (BuildContext context, int index) {
        return Container(
          height: 300,
          child: Column(
            children: [
              headLayout(model.itemList[index]),
              Expanded(
                flex: 1,
                child: FindFollowListWidget(model.itemList[index]),
              ),
            ],
          ),
        );
      },
      itemCount: model.itemList.length,
      separatorBuilder: (BuildContext context, int index) {
        return Container(
          padding: EdgeInsets.only(left: 10, right: 10),
          width: MediaQuery.of(context).size.width,
          height: 0.5,
          color: Colors.black12,
        );
      },
    );
  }

  //顶部作者信息
  Widget headLayout(ItemList itemList) {
    return Row(
      children: [
        //图片
        Padding(
          padding: EdgeInsets.all(5),
          child: cacheImage(itemList.data.header.icon,
              width: 44, height: 44, borderRadius: BorderRadius.circular(22)),
        ),
        //占满
        Expanded(
          flex: 1,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                itemList.data.header.title,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  fontSize: 15,
                  color: Colors.black54,
                  fontWeight: FontWeight.bold,
                ),
              ),
              Text(
                itemList.data.header.description,
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: TextStyle(fontSize: 13, color: Colors.black26),
              ),
            ],
          ),
        ),

        // Padding(
        //   padding: EdgeInsets.only(right: 20),
        //   child: Container(
        //     padding: EdgeInsets.all(5),
        //     decoration: BoxDecoration(
        //       color: Colors.white,
        //       borderRadius: BorderRadius.circular(5),
        //     ),
        //     child: Text(
        //       StringConfig.FOLLOW,
        //       style: TextStyle(
        //           fontWeight: FontWeight.bold,
        //           color: Colors.grey,
        //           fontSize: 12),
        //     ),
        //   ),
        // )
      ],
    );
  }
}
